<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>添加新学生</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">
  <link rel="stylesheet" href="/css/style.css?v=1.0">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-gradient">
  <div class="container">
    <a class="navbar-brand" href="#">
      <i class="fas fa-graduation-cap me-2"></i>学生信息管理系统
    </a>
  </div>
</nav>

<div class="container my-5">
  <div class="row justify-content-center">
    <div class="col-lg-8">
      <div class="card border-0 shadow rounded-4">
        <div class="card-header bg-white py-4 border-0">
          <div class="d-flex align-items-center">
            <a th:href="@{/students}" class="btn btn-light btn-sm rounded-circle me-3">
              <i class="fas fa-arrow-left"></i>
            </a>
            <div>
              <h2 class="mb-0">添加新学生</h2>
              <p class="text-muted mb-0">填写学生信息添加到系统</p>
            </div>
          </div>
        </div>
        <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
        <div class="card-body p-4 pt-0">
          <form th:action="@{/students}" th:object="${student}" method="post">
            <div class="row">
              <div class="col-md-6 mb-4">
                <label for="name" class="form-label fw-bold">姓名 <span class="text-danger">*</span></label>
                <input type="text" class="form-control form-control-lg"
                       id="name" name="name" th:field="*{name}" required>
                <div class="form-text">学生的全名</div>
              </div>
              <div class="col-md-6 mb-4">
                <label for="email" class="form-label fw-bold">邮箱 <span class="text-danger">*</span></label>
                <input type="email" class="form-control form-control-lg"
                       id="email" name="email" th:field="*{email}" required>
                <div class="form-text">有效的邮箱地址</div>
              </div>

              <div class="col-md-6 mb-4">
                <label for="phone" class="form-label fw-bold">电话 <span class="text-danger">*</span></label>
                <input type="tel" class="form-control form-control-lg"
                       id="phone" name="phone" th:field="*{phone}" required>
                <div class="form-text">格式: 138-xxxx-xxxx</div>
              </div>
              <div class="col-md-6 mb-4">
                <label for="department" class="form-label fw-bold">院系 <span class="text-danger">*</span></label>
                <select class="form-select form-select-lg"
                        id="department" name="department" th:field="*{department}" required>
                  <option value="" disabled selected>选择院系</option>
                  <option value="计算机科学">计算机科学</option>
                  <option value="电子工程">电子工程</option>
                  <option value="机械工程">机械工程</option>
                  <option value="工商管理">工商管理</option>
                  <option value="外语学院">外语学院</option>
                  <option value="数学系">数学系</option>
                  <option value="物理系">物理系</option>
                </select>
              </div>
              <div class="col-md-6 mb-4">
                <label for="year" class="form-label fw-bold">年级 <span class="text-danger">*</span></label>
                <select class="form-select form-select-lg"
                        id="year" name="year" th:field="*{year}" required>
                  <option value="">选择年级</option> <!-- 去掉disabled和selected -->
                  <option value="1">一年级</option>
                  <option value="2">二年级</option>
                  <option value="3">三年级</option>
                  <option value="4">四年级</option>
                </select>
              </div>
              <div class="col-md-12 mt-4">
                <div class="d-flex justify-content-end gap-3">
                  <a th:href="@{/students}" class="btn btn-lg btn-light px-4">取消</a>
                  <button type="submit" class="btn btn-lg btn-primary px-4">
                    <i class="fas fa-save me-2"></i>保存学生信息
                  </button></div></div></div></form></div></div></div></div></div>

<footer class="bg-light py-4 mt-5">
  <div class="container text-center">
    <p class="mb-0">© 2023 学生信息管理系统 | 添加学生</p>
  </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>